package com.wkk.nursinghome.dao;

import com.wkk.nursinghome.domain.Checkin;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface ICheckinDao {
    //根据编号查询所登记人信息
    @Select("select * from checkin where id=#{id}")
    public Checkin selectById(Integer id);

    //查询所有所登记人信息
    @Select("select * from checkin order by id asc")
    public List<Checkin> selectAll();

    //添加登记人信息
    @Insert("insert into checkin (name, sex,age,idcard,rnumber,bnumber,fnumber,citime,cetime,cnumber,family,accompany,assessmentdo,chargedo,careworker,healthsteward,operator,remarks) " +
            "values (#{name}, #{sex},#{age}, #{idcard},#{rnumber}, #{bnumber},#{fnumber}, #{citime},#{cetime}, #{cnumber},#{family}, #{accompany},#{assessmentdo},#{chargedo},#{careworker},#{healthsteward},#{operator},#{remarks})")
    @SelectKey(statement = "select LAST_INSERT_ID()",keyProperty = "id",before = false,resultType = Integer.class)
    public int insertCheckin(Checkin checkin);

    //删除所登记人信息
    @Delete("delete from checkin where id=#{id}")
    public int deleteCheckinById(Integer id);

    //修改所登记人信息
    @UpdateProvider(type = CheckinSQLProvider.class,method = "updateCheckin")
    public int updateCheckin(Checkin checkin);

    //根据条件查询所登记人信息
    @SelectProvider(type = CheckinSQLProvider.class,method = "selectCheckinByCondition")
    public List<Checkin> getCheckinByCondition(Checkin checkin);
}